package vip.xiaonuo.smzq.modular.psba.service.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import vip.xiaonuo.smzq.modular.psba.entity.GtWjglb;
import vip.xiaonuo.smzq.modular.psba.entity.PsbaSqjlJbqk;
import vip.xiaonuo.smzq.modular.psba.entity.PsbaSqjlYfjbqk;
import vip.xiaonuo.smzq.modular.psba.entity.vo.Fyfxxtb;
import vip.xiaonuo.smzq.modular.psba.entity.vo.PsbaSqjlJbqkVo;
import vip.xiaonuo.smzq.modular.psba.entity.vo.PsbaSqjlYfjbqkVo;
import vip.xiaonuo.smzq.modular.psba.entity.vo.PsbaYfxqVo;
import vip.xiaonuo.smzq.modular.psba.mapper.PsbaSqjlYfjbqkMapper;
import vip.xiaonuo.smzq.modular.psba.service.IPsbaSqjlYfjbqkService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import vip.xiaonuo.common.page.CommonPageRequest;

import javax.annotation.Resource;
import java.util.List;

/**
 * 评审备案申请记录-压覆基本情况 服务实现类
 *
 * @author Kevin
 * @since 2024-06-11
 */
@Service
public class PsbaSqjlYfjbqkServiceImpl extends ServiceImpl<PsbaSqjlYfjbqkMapper, PsbaSqjlYfjbqk> implements IPsbaSqjlYfjbqkService {

    @Resource
    private PsbaSqjlYfjbqkMapper psbaSqjlYfjbqkMapper;

    @Override
    public Page<PsbaSqjlYfjbqk> page(PsbaSqjlYfjbqk psbaSqjlYfjbqk) {
        QueryWrapper<PsbaSqjlYfjbqk> queryWrapper = new QueryWrapper<>();
        return this.page(CommonPageRequest.defaultPage(), queryWrapper);
    }

    @Override
    public PsbaSqjlYfjbqkVo getPsbaSqjlYfjbqk(String psbabh) {
        PsbaSqjlYfjbqkVo vo = new PsbaSqjlYfjbqkVo();
        MPJLambdaWrapper<PsbaSqjlYfjbqk> wrapper = new MPJLambdaWrapper<>();
        wrapper.selectAll(PsbaSqjlYfjbqk.class)
                .selectAs(GtWjglb::getWjmc, PsbaSqjlYfjbqkVo::getBgwjmc)
                .leftJoin(GtWjglb.class, GtWjglb::getPkid, PsbaSqjlYfjbqk::getBgwj)
                .eq(PsbaSqjlYfjbqk::getPsbabh, psbabh);
        List<PsbaSqjlYfjbqkVo> list = psbaSqjlYfjbqkMapper.selectJoinList(PsbaSqjlYfjbqkVo.class, wrapper);
        if (CollectionUtil.isNotEmpty(list)) {
            vo = list.get(0);
        }
        return vo;
    }

}
